package com.lanyam.travel.base.dao;

import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lanyam.travel.base.entity.Role;
import com.lanyam.travel.base.entity.User;
import com.lanyam.travel.base.entity.vo.FormReport;
import com.lanyam.travel.base.entity.vo.TravelOrderVo;
import com.lanyam.travel.base.entity.vo.UserVo;

@Repository
public interface UserMapper extends BaseMapper<User>{

	@Select("select * from role where id =(select role_id from user where id = #{userId})")
	Role selectRoleInUser(String userId);

	@Update("update user set role_id = #{roleId} where id = #{userId}")
	void updateUserRole(String userId, String roleId);

	/**
	 * 根据电话好嘛获取用户
	 * @param phone
	 * @return
	 */
	List<User> getByPhone(String phone);

	List<FormReport> getUserCountByDays(@Param("map") Map<String, String> reqMap);

	Page<UserVo> queryAdminPage(Page<UserVo> page,@Param("map") Map<String, Object> map);

	UserVo getUserById(String id);

	/**
	 * 查询用户分页数据
	 * @param page
	 * @param map
	 * @return
	 */
	Page<UserVo> getPage(@Param("page") IPage<UserVo> page, @Param("map") Map<String, Object> map);
}
